#pragma once
#include "Runtime/BattleFirePrefix.h"
class FThreadSafeCounter
{
public:
	typedef BattleFireSInt32 IntegerType;
	FThreadSafeCounter()
	{
		Counter = 0;
	}
	FThreadSafeCounter(const FThreadSafeCounter& Other)
	{
		Counter = Other.GetValue();
	}
	FThreadSafeCounter(BattleFireSInt32 Value)
	{
		Counter = Value;
	}
	BattleFireSInt32 Increment()
	{
		return ++Counter;
	}
	BattleFireSInt32 Add(BattleFireSInt32 Amount)
	{
		return Counter.fetch_add(Amount);
	}
	BattleFireSInt32 Decrement()
	{
		return --Counter;
	}
	BattleFireSInt32 Subtract(BattleFireSInt32 Amount)
	{
		return Counter.fetch_sub(Amount);
	}
	BattleFireSInt32 Set(BattleFireSInt32 Value)
	{
		return Counter.exchange(Value);
	}
	BattleFireSInt32 Reset()
	{
		return Counter.exchange(0);
	} 
	BattleFireSInt32 GetValue() const
	{
		return Counter.load();
	}
private:
	void operator=(const FThreadSafeCounter& Other) {}
	std::atomic<BattleFireSInt32> Counter;
};
